/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = activemq_base_type.h                               */
/*  NOTE      =                                                    */
/*  DATE      = 2015/04/28 by geyh                                 */
/*******************************************************************/
#ifndef __ACTIVEMQ_BASE_TYPE_H_
#define __ACTIVEMQ_BASE_TYPE_H_

#include "conntrack.h"
#include "module.h"
#include "frbyte_buffer.h"
#include "frlist.h"
#include "frreport_comm.h"

typedef struct __st_L7session_activeMQ_private
{
    unsigned long ul_seq;                             /* 序列号，1次req和response时，使用同一个序列号 */
    int i_data_len;                                    /* 数据长度 */
    Frlist_header *p_lst_comm_tmp;                          //数据  activeMQ comm
    Frlist_header *p_lst_req_tmp;                          //数据  activeMQ req
    Frlist_header *p_lst_mq_tmp;                          //数据  activeMQ req

    Frreport_body_data *p_st_body_data_req;
    Frreport_body_data *p_st_body_data_resp;

    L4_transaction st_l4_trans;                         /* 数据 */
    Frbyte_Packet *p_st_data;
    int i_flag_data_type;
    int i_flag_responserequired;
    int i_tightEncodingEnabled;
    int i_cacheEnabled;

    int i_flag_try;                                     //长连接 数据解析尝试
    int i_flag_detected;                                //长连接 解析方式可确定   response包不能判断 i_tightEncodingEnabled

    int i_use_request;
    int is_topic;
    int is_producer;
    int is_messages;

    char *p_user_name;
    struct timeval st_login_timestamp;
    char arr_session_id[APM_UUID_SIZE];
    char *p_server;
    char *p_title;
    int i_openwire_version;
    int i_message_type;                                 //  1:map    2:text     3:stream bin
    int i_skip_len;

    int i_flag_report;                                  //  数据是否上报   1上报

}L7session_activeMQ_private;

/* command type*/

/*
* Info objects sent back and forth client/server when
* setting up a client connection.
*/
#define ACTIVEMQ_WIREFORMAT_INFO                                0x01
#define ACTIVEMQ_BROKER_INFO                                    0x02
#define ACTIVEMQ_CONNECTION_INFO                                0x03
#define ACTIVEMQ_SESSION_INFO                                   0x04
#define ACTIVEMQ_CONSUMER_INFO                                  0x05
#define ACTIVEMQ_PRODUCER_INFO                                  0x06
#define ACTIVEMQ_TRANSACTION_INFO                               0x07
#define ACTIVEMQ_DESTINATION_INFO                               0x08
#define ACTIVEMQ_REMOVE_SUBSCRIPTION_INFO                       0x09
#define ACTIVEMQ_KEEP_ALIVE_INFO                                0x0a
#define ACTIVEMQ_SHUTDOWN_INFO                                  0x0b
#define ACTIVEMQ_REMOVE_INFO                                    0x0c
#define ACTIVEMQ_CONTROL_COMMAND                                0x0e
#define ACTIVEMQ_FLUSH_COMMAND                                  0x0f   
#define ACTIVEMQ_CONNECTION_ERROR                               0x10
#define ACTIVEMQ_CONSUMER_CONTROL                               0x11
#define ACTIVEMQ_CONNECTION_CONTROL                             0x12

/*
* Messages that go back and forth between the client
* and the server.
*/
#define ACTIVEMQ_PRODUCER_ACK                                   0x13
#define ACTIVEMQ_MESSAGE_PULL                                   0x14
#define ACTIVEMQ_MESSAGE_DISPATCH                               0x15
#define ACTIVEMQ_MESSAGE_ACK                                    0x16

#define ACTIVEMQ_ACTIVEMQ_MESSAGE                               0x17
#define ACTIVEMQ_ACTIVEMQ_BYTES_MESSAGE                         0x18
#define ACTIVEMQ_ACTIVEMQ_MAP_MESSAGE                           0x19
#define ACTIVEMQ_ACTIVEMQ_OBJECT_MESSAGE                        0x1a
#define ACTIVEMQ_ACTIVEMQ_STREAM_MESSAGE                        0x1b
#define ACTIVEMQ_ACTIVEMQ_TEXT_MESSAGE                          0x1c
#define ACTIVEMQ_ACTIVEMQ_BLOB_MESSAGE                          0x1d

/*
* Command Response messages
*
*/
#define ACTIVEMQ_RESPONSE                                       0x1e
#define ACTIVEMQ_EXCEPTION_RESPONSE                             0x1f
#define ACTIVEMQ_DATA_RESPONSE                                  0x20
#define ACTIVEMQ_DATA_ARRAY_RESPONSE                            0x21
#define ACTIVEMQ_INTEGER_RESPONSE                               0x22

/*
* Used by discovery
*/
#define ACTIVEMQ_DISCOVERY_EVENT                                0x28


/*
* Command object used by the Journal
*/
#define ACTIVEMQ_JOURNAL_ACK                                    0x32
#define ACTIVEMQ_JOURNAL_REMOVE                                 0x34
#define ACTIVEMQ_JOURNAL_TRACE                                  0x35
#define ACTIVEMQ_JOURNAL_TRANSACTION                            0x36
#define ACTIVEMQ_DURABLE_SUBSCRIPTION_INFO                      0x37


/*
* Reliability and fragmentation
*/
#define ACTIVEMQ_PARTIAL_COMMAND                                0x3c
#define ACTIVEMQ_PARTIAL_LAST_COMMAND                           0x3d

#define ACTIVEMQ_REPLAY                                         0x41

/*
* Types used represent basic Java types.
*/
#define ACTIVEMQ_BYTE_TYPE                                      0x46
#define ACTIVEMQ_CHAR_TYPE                                      0x47
#define ACTIVEMQ_SHORT_TYPE                                     0x48
#define ACTIVEMQ_INTEGER_TYPE                                   0x49
#define ACTIVEMQ_LONG_TYPE                                      0x4a
#define ACTIVEMQ_DOUBLE_TYPE                                    0x4b
#define ACTIVEMQ_FLOAT_TYPE                                     0x4c
#define ACTIVEMQ_STRING_TYPE                                    0x4d
#define ACTIVEMQ_BOOLEAN_TYPE                                   0x4e
#define ACTIVEMQ_BYTE_ARRAY_TYPE                                0x4f

/*
* Broker to Broker command objects
*/
#define ACTIVEMQ_MESSAGE_DISPATCH_NOTIFICATION                  0x5a
#define ACTIVEMQ_NETWORK_BRIDGE_FILTER                          0x5b

/*
* Data structures contained in the command objects.
*/
#define ACTIVEMQ_ACTIVEMQ_QUEUE                                 0x64
#define ACTIVEMQ_ACTIVEMQ_TOPIC                                 0x65
#define ACTIVEMQ_ACTIVEMQ_TEMP_QUEUE                            0x66
#define ACTIVEMQ_ACTIVEMQ_TEMP_TOPIC                            0x67

#define ACTIVEMQ_MESSAGE_ID                                     0x6e
#define ACTIVEMQ_ACTIVEMQ_LOCAL_TRANSACTION_ID                  0x6f
#define ACTIVEMQ_ACTIVEMQ_XA_TRANSACTION_ID                     0x70

#define ACTIVEMQ_CONNECTION_ID                                  0x78
#define ACTIVEMQ_SESSION_ID                                     0x79
#define ACTIVEMQ_CONSUMER_ID                                    0x7a
#define ACTIVEMQ_PRODUCER_ID                                    0x7b
#define ACTIVEMQ_BROKER_ID                                      0x7c


/*  ACTIVEMQ DATA TYPE  */
#define ACTIVEMQ_DATA_NULL              0
#define ACTIVEMQ_DATA_BOOLEAN           1
#define ACTIVEMQ_DATA_BYTE              2
#define ACTIVEMQ_DATA_CHAR              3
#define ACTIVEMQ_DATA_SHORT             4
#define ACTIVEMQ_DATA_INTEGER           5
#define ACTIVEMQ_DATA_LONG              6
#define ACTIVEMQ_DATA_DOUBLE            7
#define ACTIVEMQ_DATA_FLOAT             8
#define ACTIVEMQ_DATA_STRING            9
#define ACTIVEMQ_DATA_ARRAY             10
#define ACTIVEMQ_DATA_MAP               11
#define ACTIVEMQ_DATA_LIST              12
#define ACTIVEMQ_DATA_BIG_STRING        13


typedef struct __ACTIVEMQ_boolean_stream
{
    char *p_boolean_data;                        //布尔型数据
    unsigned short us_arraylimit;              //布尔型数据长度
    unsigned short us_arraypos;                //指向字节位数
    unsigned short us_bytepos;                 //字节中的bit位

} ACTIVEMQ_boolean;

#endif
